#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/wait.h>

int main()
{
  pid_t id = fork();
  if(id == 0)
  {

    printf("before : i am a process, pid : %d, ppid : %d\n", getpid(), getppid());
    sleep(5);
    //execl("/usr/bin/top","top",NULL);

    execl("/usr/bin/ls","ls", "-a", "-l", NULL);
    printf("after : i am a process, pid : %d, ppid : %d\n", getpid(), getppid());
  }
  
  // father
  pid_t ret = waitpid(id, NULL, 0);
  if(ret > 0)
  {
    printf("wait successful, father pid : %d, ret id : %d\n", getpid(), ret);
  }

  sleep(5);

  return 0;
}
